package com.google.memoryofaplace.model;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TBDenounces {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String encodedKey;

	@Persistent
	@Extension(vendorName = "datanucleus", key = "gae.pk-id", value = "true")
	private Long codDenounce;

	@Persistent
	private Long codPlace;

	@Persistent
	private Long codDenouncedObject;
	
	@Persistent
	private Date creation;

	@Persistent
	private Long counter;

	@Persistent
	private int denounceType;

	@Persistent
	private int denounceObjectType;

	public void setEncodedKey(String encodedKey) {
		this.encodedKey = encodedKey;
	}

	public String getEncodedKey() {
		return encodedKey;
	}

	public void setCreation(Date creation) {
		this.creation = creation;
	}

	public Date getCreation() {
		return creation;
	}

	public void setDenounceType(int denounceType) {
		this.denounceType = denounceType;
	}

	public int getDenounceType() {
		return denounceType;
	}

	public void setCodDenounce(Long codDenounce) {
		this.codDenounce = codDenounce;
	}

	public Long getCodDenounce() {
		return codDenounce;
	}


	public TBDenounces(int denounceType) {
		super();
		this.denounceType = denounceType;
		this.creation = new Date();
	}

	public TBDenounces(long codPlace, long codDenouncedObject,
			int denounceObjectType, int denounceType) {
		super();		
		this.codPlace = codPlace;		
		this.codDenouncedObject = codDenouncedObject;
		this.denounceObjectType = denounceObjectType;
		this.denounceType = denounceType;
		this.creation = new Date();
	}

	public void setCounter(Long counter) {
		this.counter = counter;
	}

	public Long getCounter() {
		return counter;
	}


	public Long increaseDenounces() {
		counter++;
		return counter;
	}

	public Long decreaseDenounces() {
		if (counter>0)
			counter--;		
		return counter;
	}

	public void setDenounceObjectType(int denounceObjectType) {
		this.denounceObjectType = denounceObjectType;
	}

	public int getDenounceObjectType() {
		return denounceObjectType;
	}

	public void setCodDenouncedObject(Long codDenouncedObject) {
		this.codDenouncedObject = codDenouncedObject;
	}

	public Long getCodDenouncedObject() {
		return codDenouncedObject;
	}

	public void setCodPlace(Long codPlace) {
		this.codPlace = codPlace;
	}

	public Long getCodPlace() {
		return codPlace;
	}
	
}
